<!DOCTYPE html>
<html lang="{{ session['lang'] }}">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <meta name="keywords" content="{{ config['WEBSITE_KEYWORDS'] }}">
        {% block head %}{% endblock %}
        <link href="{{ url_for('static', filename='vendors/font-awesome/css/font-awesome.min.css') }}" rel="stylesheet">
        <link rel="stylesheet" href="{{ url_for('static', filename='vendors/bootstrap/bootstrap.min.css') }}">        
        <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">        
        <link rel="stylesheet" href="{{ url_for('static', filename='vendors/highlight.js/default.min.css') }}">        
        <link rel="shortcut icon" type="image/x-icon" href="{{ url_for('static', filename=config['FAVICON']) }}">
        {% from "wiki/toolbar.html" import toolbar with context %}    
        {% if session["direction"] == "rtl" %}
            <style type="text/css">
                .navbar-nav li {
                    float: right;
                }
                .dropdown-menu {
                    text-align: right !important;
                }
                .dropdown-menu li {
                    width: 100%;
                }
            </style>
        {% endif %}
        <style type="text/css">
            @media only screen and (max-width: 768px) {
                .navbar-nav li {
                    float: none;
                }
            }
        </style>
    </head>

    {% if session["direction"] == "rtl" %}
        <body dir="rtl" bgcolor="#CBF1FF">
    {% else %}
        <body dir="ltr" bgcolor="#CBF1FF">    
    {% endif %}
        <nav class="navbar navbar-inverse" role="navigation">
            <div class="container">
                {% if session["direction"] == "rtl" %}
                    <div class="navbar-header navbar-right">
                {% else %}
                    <div class="navbar-header navbar-left">
                {% endif %}
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
                        <span class="sr-only">Menu</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="{{ url_for('wiki.index') }}"><img src="{{ url_for('static', filename=_(config['WEBSITE_LOGO'])) }}" alt="{{ _(config['WEBSITE_NAME']) }} {{ _('logo') }}"></a>
                </div>
                <div id="navbar" class="collapse navbar-collapse">
                    {% if session["direction"] == "rtl" %}
                        <ul class="nav navbar-nav navbar-left">                    
                    {% else %}
                        <ul class="nav navbar-nav navbar-right">                    
                    {% endif %}
                        {% if session.logged_in %}
                            <li><a href="{{ url_for('wiki.user_profile', username=session.current_user.username) }}">{{ _("Profile") }}</a></li>
                            {% if session.get("current_user")["privilege"] == "admin" %}
                                <li><a href="{{ url_for('admin.index') }}">{{ _("Dashboard") }}</a></li>
                            {% endif %}   
                        {% else %}
                            <li><a href="{{ url_for('wiki.login') }}">{{ _("Login") }}</a></li>
                            <li><a href="{{ url_for('wiki.signup') }}">{{ _("Sign Up") }}</a></li>
                        {% endif %}
                        <li class="dropdown">
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#">{{ _("Pages") }}
                                <span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu">
                                {% if "PAGES" in config %}
                                    {% if len(config["PAGES"]) != 0 and type(config["PAGES"]) == dict %}
                                        {% for page in config["PAGES"].items() %}
                                            <li><a style="color: #000 !important" href="{{ page[1] }}">{{ _(page[0]) }}</a></li>
                                        {% endfor %}
                                    {% endif %}
                                {% endif %}
                            </ul>
                        </li>
                        <li class="dropdown">
                            <a class="dropdown-toggle" data-toggle="dropdown" href="#">{{ _("Langs") }}
                                <span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu">
                                {% for lang in sorted(config["LANGUAGES"].keys()) %}
                                    <li><a style="color: #000 !important" href="{{ url_for('wiki.langchanger', lang=lang[0:2].lower()) }}">{{ _(lang) }}</a></li>
                                {% endfor %}
                            </ul>
                        </li>
                        {% if session.logged_in %}
                            <li><a href="{{ url_for('wiki.logout') }}">{{ _("Logout") }}</a></li>
                        {% endif %}
                    </ul>
                </div>
            </div>
        </nav>    
        <main>{% block body %} {% endblock %}</main>
        <footer class="footer">
            <p>{{ _(config["FOOTER_MESSAGE"]) }}</p>
        </footer>
        <script src="{{ url_for('static', filename='vendors/highlight.js/highlight.min.js') }}"></script>
        <script src="{{ url_for('static', filename='vendors/jquery/jquery.min.js') }}"></script>
        <script src="{{ url_for('static', filename='vendors/bootstrap/bootstrap.min.js') }}"></script>
        {% block js %}{% endblock %}
    </body>
</html>